package br.com.locanet.view.impl;

import javax.faces.bean.ManagedBean;

import br.com.locanet.bean.impl.Cliente;
import br.com.locanet.service.impl.ClienteService;
import br.com.locanet.view.AbstractManagedBean;

@ManagedBean(name="clienteBean")
public class ClientesBean extends
		AbstractManagedBean<Cliente, ClienteService> {
	private String conf_senha;
	
	public String insert() throws Exception {
		getEntity().setStatus(1);

		getEntityService().doValidateSenha(getEntity(),getConf_senha());
		
		return super.insert();
	}
	
	@Override
	public String remove() throws Exception {
		doExclusaoLogica(getEntity());
		return search();
	}
	private void doExclusaoLogica(Cliente clie) throws Exception {
		clie = getEntityService().selectById(clie);
		clie.setStatus(clie.getStatus() == 1 ? 0 : 1);
		getEntityService().update(clie);
	}

	public String getConf_senha() {
		return conf_senha;
	}

	public void setConf_senha(String confSenha) {
		conf_senha = confSenha;
	}
	
}
